import { CRON_OPTIONS } from './constants';

export const formatNumber = (numStr: string): string => {
  const num = parseInt(numStr, 10);
  return isNaN(num) ? numStr : num.toString();
};

export const validateRange = (value: number, min: number, max: number): boolean => {
  return value >= min && value <= max;
};

export const generateNumbers = (count: number, start: number = 0): number[] => {
  return Array.from({ length: count }, (_, i) => i + start);
};

export const getFieldLimits = (fieldType: string) => {
  switch (fieldType) {
    case 'second': return CRON_OPTIONS.SECOND;
    case 'minute': return CRON_OPTIONS.MINUTE;
    case 'hour': return CRON_OPTIONS.HOUR;
    case 'day': return CRON_OPTIONS.DAY;
    case 'month': return CRON_OPTIONS.MONTH;
    case 'week': return CRON_OPTIONS.WEEK;
    case 'year': return CRON_OPTIONS.YEAR;
    default: return { min: 0, max: 59 };
  }
};